import request from './request.js'
import { ensureConfigInitialized, serviceUrl } from '../config/config.js'
import log from '../logger.js'

export async function makeAudio(param) {
  // 确保配置初始化完成
  await ensureConfigInitialized();

  const http_url = serviceUrl.tts
  log.debug('~ makeAudio ~ param:', JSON.stringify(param))
  return request.post(`${http_url}/v1/invoke`, param, {
    responseType: 'arraybuffer'
  })
}
